package geradatawarehouse.main;

import geradatawarehouse.runnable.AlunoEJAWorker;
import geradatawarehouse.runnable.AlunoRegularWorker;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

public class GeraDataWarehouse {

	private static final Logger LOGGER = Logger
			.getLogger(GeraDataWarehouse.class);

	/**
	 * @param args
	 * @throws SQLException
	 * @throws IOException
	 * @throws InterruptedException
	 */
	public static void main(final String[] args) throws SQLException,
			IOException, InterruptedException {

		GeraDataWarehouse.LOGGER.info("Iniciando a atualização");

		final List<Thread> listaThreads = new ArrayList<Thread>();

		final Thread alunoRegularThread = new Thread(new AlunoRegularWorker(),
				"AlunoRegularWorker");
		listaThreads.add(alunoRegularThread);

		final Thread alunoEJAThread = new Thread(new AlunoEJAWorker(),
				"AlunoEJAWorker");
		listaThreads.add(alunoEJAThread);

		for (final Thread thread : listaThreads) {
			thread.start();
		}

		for (final Thread thread : listaThreads) {
			thread.join();
		}

		GeraDataWarehouse.LOGGER.info("Atualização finalizada.");

	}
}
